<?php

namespace teach\controllers;

use teach\service\Category;
use teach\service\Menu;
use teach\util\helper\ResponseHelper;
use Yii;
use yii\filters\VerbFilter;
use yii\web\Controller;

class CategoryController extends Controller
{
    public $enableCsrfValidation = false;

    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::class,
                'actions' => [
                    '*' => ['post'],
                ],
            ],
        ];
    }

    /**
     * 获取菜单列表
     * @return \yii\web\Response
     */
    public function actionList()
    {
        $map = ' status = 1 ';
        $categories = new Category();
        $categoryList = $categories->CategoryList($map);
        $jsonData = ResponseHelper::buildJsonData(200, '成功', $categoryList);

        return $this->asJson($jsonData);
    }
}